package com.artezio.buyndrive.dao.impl;

import com.artezio.buyndrive.dao.CarserviceDAO;
import com.artezio.buyndrive.domain.Carservice;
import com.artezio.buyndrive.domain.Users;
import java.util.List;
import org.hibernate.SessionFactory;

import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class CarserviceDAOImpl extends AbstractHibernateDao<Carservice> 
    implements CarserviceDAO{

    @Autowired
    private SessionFactory sessionFactory;
    
    @Autowired
    public CarserviceDAOImpl(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }

    @Override
    public List<Carservice> getListCarservices(Users user) {
        return sessionFactory.getCurrentSession()
		.createCriteria(Carservice.class)
                .add(Restrictions.eq("idUsers", user)).list();
    }
   
}
